<?php
namespace includes;
/**
 * Description of DateTime
 *
 * @author John
 */
class DutchDateConversion {
    
    //expects date as ex. 1 januari 2000
    public static function formatDate( $date ) {
	$months = array(1=>'januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december');
	$validMonthFound = false;
	
	$date = explode(" ", $date);
	if(isset($date[1])) {
	    foreach($months as $monthNumber=>$monthName) {
		if($monthName == $date[1]) {
		    if($monthNumber < 10)
			$monthNumber = "0$monthNumber";
		    $date[1] = $monthNumber;
		    $validMonthFound = true;
		    break;
		}
		if(!$validMonthFound)
		    return implode(" ",$date);
	    }
	    
	    return "{$date[2]}-{$date[1]}-{$date[0]}";
	}
	return implode("",$date);
    }
}

?>
